package com.ruoyi.configuration.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.configuration.mapper.MgPreStoredRewardsConfMapper;
import com.ruoyi.configuration.domain.MgPreStoredRewardsConf;
import com.ruoyi.configuration.service.IMgPreStoredRewardsConfService;

/**
 * 预存奖励设置Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-16
 */
@Service
public class MgPreStoredRewardsConfServiceImpl implements IMgPreStoredRewardsConfService 
{
    @Autowired
    private MgPreStoredRewardsConfMapper mgPreStoredRewardsConfMapper;

    /**
     * 查询预存奖励设置
     * 
     * @param id 预存奖励设置主键
     * @return 预存奖励设置
     */
    @Override
    public MgPreStoredRewardsConf selectMgPreStoredRewardsConfById(String id)
    {
        return mgPreStoredRewardsConfMapper.selectMgPreStoredRewardsConfById(id);
    }

    /**
     * 查询预存奖励设置列表
     * 
     * @param mgPreStoredRewardsConf 预存奖励设置
     * @return 预存奖励设置
     */
    @Override
    public List<MgPreStoredRewardsConf> selectMgPreStoredRewardsConfList(MgPreStoredRewardsConf mgPreStoredRewardsConf)
    {
        return mgPreStoredRewardsConfMapper.selectMgPreStoredRewardsConfList(mgPreStoredRewardsConf);
    }

    /**
     * 新增预存奖励设置
     * 
     * @param mgPreStoredRewardsConf 预存奖励设置
     * @return 结果
     */
    @Override
    public int insertMgPreStoredRewardsConf(MgPreStoredRewardsConf mgPreStoredRewardsConf)
    {
        mgPreStoredRewardsConf.setCreateTime(DateUtils.getNowDate());
        mgPreStoredRewardsConf.setUpdateTime(DateUtils.getNowDate());
        if(mgPreStoredRewardsConf.getType()==0L){
            mgPreStoredRewardsConf.setPriceEnd(BigDecimal.ZERO);
        }
        return mgPreStoredRewardsConfMapper.insertMgPreStoredRewardsConf(mgPreStoredRewardsConf);
    }

    /**
     * 修改预存奖励设置
     * 
     * @param mgPreStoredRewardsConf 预存奖励设置
     * @return 结果
     */
    @Override
    public int updateMgPreStoredRewardsConf(MgPreStoredRewardsConf mgPreStoredRewardsConf)
    {
        mgPreStoredRewardsConf.setUpdateTime(DateUtils.getNowDate());
        if(mgPreStoredRewardsConf.getType()==0L){
            mgPreStoredRewardsConf.setPriceEnd(BigDecimal.ZERO);
        }
        String remarks = mgPreStoredRewardsConf.getRemarks();
        mgPreStoredRewardsConfMapper.updateRemarks(remarks);
        return mgPreStoredRewardsConfMapper.updateMgPreStoredRewardsConf(mgPreStoredRewardsConf);
    }

    /**
     * 批量删除预存奖励设置
     * 
     * @param ids 需要删除的预存奖励设置主键
     * @return 结果
     */
    @Override
    public int deleteMgPreStoredRewardsConfByIds(String[] ids)
    {
        return mgPreStoredRewardsConfMapper.deleteMgPreStoredRewardsConfByIds(ids);
    }

    /**
     * 删除预存奖励设置信息
     * 
     * @param id 预存奖励设置主键
     * @return 结果
     */
    @Override
    public int deleteMgPreStoredRewardsConfById(String id)
    {
        return mgPreStoredRewardsConfMapper.deleteMgPreStoredRewardsConfById(id);
    }

	
}
